﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TreeManagement
{
    public partial class RoadForm : Form
    {
        public RoadForm()
        {
            InitializeComponent();
        }

        private void RoadForm_Load(object sender, EventArgs e)
        {
            using (var context = new TreeDBEntities())
            {
                dgvView.DataSource = context.Roads.ToList();
                viewPanel1.WardPoints = TMUtils.getWardPoints(context);
                viewPanel1.RoadPoints = TMUtils.getRoadPoints(context);
                viewPanel1.Refresh();
            }
        }
        public void reload()
        {
            using (var context = new TreeDBEntities())
            {
                dgvView.DataSource = context.Roads.ToList();
                viewPanel1.WardPoints = TMUtils.getWardPoints(context);
                viewPanel1.RoadPoints = TMUtils.getRoadPoints(context);
                viewPanel1.Refresh();
            }
        }
        private void btnNew_Click(object sender, EventArgs e)
        {
            EditRoadForm frm = new EditRoadForm();
            frm.ActionType = ActionType.NEW_ROAD;
            frm.EditRoadParent = this;
            frm.ShowDialog();
        }
    }
}
